var tagDs, keyDs, crossDs;
var mainPanel;
var keyCrossBtn, searchBtn;
var keySiteFlag = '', tagSiteFlag = '', crossKeyFlag = '', globleSiteName = '';

function displaySearchPreview() {
	Ext.form.Field.prototype.msgTarget = 'side';
	Ext.QuickTips.init();

	// 关键字表格
	keyDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			fields : [ {
				name : 'p_type'
			}, {
				name : 'p_num',
				type : 'int'
			}, {
				name : 'k_num',
				type : 'int'
			} ]
		})
	});
	keyDs.baseParams = {
		cmd : 'keysubject',
		action : 'findProAndKeyNumInPTypes'
	};
	var keySm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});

	var keyCm = new Ext.grid.ColumnModel(
			[
					new Ext.grid.RowNumberer(),
					{
						header : '信息垂直分类',
						dataIndex : 'p_type',
						width : 450,
						renderer : function(value, metadata, record) {
							if (value == 'totalCount')
								return '<div style="color:green;text-align:right;"><b><a href="javascript:keyDetail(\'all\','
										+ record.get('p_num')
										+ ','
										+ record.get('k_num')
										+ ')" ext:qtip=\'查看全部关键字分布情况\'>'
										+ value + '</a>：</b></div>';
							else if (value.length >= 40)
								return '<a HREF="javascript:keyDetail(\''
										+ Ext.util.Format.htmlEncode(value)
										+ '\',' + record.get('p_num') + ','
										+ record.get('k_num')
										+ ')"><div ext:qtip=\'' + value + '\'>'
										+ value.substring(0, 39)
										+ '...</div></a>';
							else if (value != '')
								return '<a HREF="javascript:keyDetail(\''
										+ Ext.util.Format.htmlEncode(value)
										+ '\',' + record.get('p_num') + ','
										+ record.get('k_num') + ')">' + value
										+ '</a>';
							else
								return '<a HREF="javascript:keyDetail(\'\','
										+ record.get('p_num')
										+ ','
										+ record.get('k_num')
										+ ')"><div style="background:#00CCCC;width:30px;">&nbsp;</div></a>';
						}
					},
					{
						header : '节目数',
						dataIndex : 'p_num',
						width : 95,
						sortable : false,
						renderer : function(value, metadata, record) {
							if (record.get('p_type') == 'totalCount')
								return '<span style="color:green;"><b>' + value
										+ '</b></span>';
							else
								return value;
						}
					},
					{
						header : '关键字数',
						dataIndex : 'k_num',
						width : 95,
						sortable : false,
						renderer : function(value, metadata, record) {
							if (record.get('p_type') == 'totalCount')
								return '<span style="color:green;"><b>' + value
										+ '</b></span>';
							else
								return value;
						}
					} ]);

	var keyGrid = new Ext.grid.GridPanel({
		border : false,
		region : 'center',
		ds : keyDs,
		cm : keyCm,
		sm : keySm,
		stripeRows : true,
		loadMask : {
			msg : 'key loading..'
		}
	});

	// 关键字表格标签表格
	var tagSm = new Ext.grid.RowSelectionModel({
		singleSelect : true
	});
	tagDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			fields : [ {
				name : 'p_type'
			}, {
				name : 'p_num',
				type : 'int'
			}, {
				name : 'k_num',
				type : 'int'
			} ]
		})
	});
	tagDs.baseParams = {
		cmd : 'keysubject',
		action : 'findProAndTagNumInPTypes'
	};
	var tagCm = new Ext.grid.ColumnModel(
			[
					new Ext.grid.RowNumberer(),
					{
						header : '信息垂直分类',
						dataIndex : 'p_type',
						width : 450,
						renderer : function(value, metadata, record) {
							if (value == 'totalCount')
								return '<div style="color:blue;text-align:right;"><b><a href="javascript:tagDetail(\'all\','
										+ record.get('p_num')
										+ ','
										+ record.get('k_num')
										+ ')" ext:qtip=\'查看全部关键字分布情况\'>'
										+ value + '</a>：</b></div>';
							else if (value.length >= 40)
								return '<a HREF="javascript:tagDetail(\''
										+ Ext.util.Format.htmlEncode(value)
										+ '\',' + record.get('p_num') + ','
										+ record.get('k_num')
										+ ')"><div ext:qtip=\'' + value + '\'>'
										+ value.substring(0, 39)
										+ '...</div></a>';
							else if (value != '')
								return '<a HREF="javascript:tagDetail(\''
										+ Ext.util.Format.htmlEncode(value)
										+ '\',' + record.get('p_num') + ','
										+ record.get('k_num') + ')">' + value
										+ '</a>';
							else
								return '<a HREF="javascript:tagDetail(\'\','
										+ record.get('p_num')
										+ ','
										+ record.get('k_num')
										+ ')"><div style="background:#00CCCC;width:30px;">&nbsp;</div></a>';
						}
					},
					{
						header : '节目数',
						dataIndex : 'p_num',
						width : 95,
						sortable : false,
						renderer : function(value, metadata, record) {
							if (record.get('p_type') == 'totalCount')
								return '<span style="color:blue;"><b>' + value
										+ '</b></span>';
							else
								return value;
						}
					},
					{
						header : '标签数',
						dataIndex : 'k_num',
						width : 95,
						sortable : false,
						renderer : function(value, metadata, record) {
							if (record.get('p_type') == 'totalCount')
								return '<span style="color:blue;"><b>' + value
										+ '</b></span>';
							else
								return value;
						}
					} ]);

	var tagGrid = new Ext.grid.GridPanel({
		border : false,
		region : 'center',
		ds : tagDs,
		cm : tagCm,
		sm : tagSm,
		stripeRows : true,
		loadMask : true
	});

	keyCrossBtn = new Ext.Button({
		text : '关键交叉比较',
		tooltip : '关键交叉比较',
		iconCls : 'icoEdit',
		handler : function() {
			keyCross();
		}
	});

	searchBtn = new Ext.Button({
		text : TXT_common_search,
		tooltip : TXT_common_search,
		iconCls : 'icoEdit',
		handler : function() {
			loadGrid();
		}
	});

	mainPanel = new Ext.TabPanel({
		region : 'center',
		deferredRender : false,
		activeTab : 0,
		tbar : [ '-', keyCrossBtn, '->', searchBtn, '-' ],
		items : [ {
			contentEl : 'center1',
			id : 'keyPanel',
			layout : 'border',
			title : '关键字统计',
			closable : false,
			autoScroll : true,
			listeners : {
				activate : handleActivate,
				deactivate : function() {
					keyCrossBtn.hide();
				}
			},
			items : [ keyGrid ]
		}, {
			contentEl : 'center2',
			layout : 'border',
			id : 'tagPanel',
			title : '标签统计',
			listeners : {
				activate : handleActivate
			},
			closable : false,
			autoScroll : true,
			items : [ tagGrid ]
		} ]
	});
	BestvSearch.glb_mainPanel.add(mainPanel);
	BestvSearch.drawMainFrame(TXT_app_name + ' - ' + TXT_search_title, null);

	// 排序
	tagDs.on('load', function(ds) {
		ds.sort('p_num', 'DESC');
	});
	keyDs.on('load', function(ds) {
		ds.sort('p_num', 'DESC');
	});

	// 表头点击排序
	keyGrid.on('headerclick', function(grid, index, e) {
		if (index == 2)
			keyDs.sort('p_num', 'DESC');
		else if (index == 3)
			keyDs.sort('k_num', 'DESC');
	});
	tagGrid.on('headerclick', function(grid, index, e) {
		if (index == 2)
			tagDs.sort('p_num', 'DESC');
		else if (index == 3)
			tagDs.sort('k_num', 'DESC');
	});

	keyDs.load({
		params : {
			start : 0,
			limit : 2
		},
		callback : function(r, options, success) {
			if (r.length == 0) {
				Ext.MessageBox.alert(TXT_common_hint, TXT_common_relogin,
						function() {
							window.location.href = '../eni/common/logout.jsp';
						});
				return;
			}
		}
	});
}

// 关键字详细信息
function keyDetail(value, pnum, knum) {
	var keywordDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			fields : [ {
				name : 'keyword'
			}, {
				name : 'num'
			} ]
		})
	});
	keywordDs.baseParams = {
		cmd : 'keysubject',
		action : 'findEachKeyAndNumInPType',
		ptype : value,
		count : knum
	};
	var html;
	html = '<table><tr style="height:8px"><td colspan=2></td></tr>';
	html += '<tr><td style="width:10px"></td><td>节目总数(Program)： ' + pnum
			+ '</td></tr><tr style="height:3px"><td colspan=2></td></tr>';
	html += '<tr><td style="width:10px"></td><td>关键字总数(keywords)： ' + knum
			+ '</td></tr><tr style="height:5px"><td colspan=2></td></tr>';
	html += '</table>';

	keySiteFlag = BestvSearch.DataSourceKey;
	mainPanel
			.add(
					{
						title : '('
								+ globleSiteName
								+ ')'
								+ (value.length > 4 ? (value.substring(0, 4) + '...')
										: value) + ':关键字',
						tabTip : '(' + globleSiteName + ')' + value + ':关键字',
						id : keySiteFlag + '_' + 'key_'
								+ value.replace(/"/g, 'tags_s'),
						layout : 'fit',
						iconCls : 'tabs',
						html : '<div id="totalPanel_key_'
								+ keySiteFlag
								+ '_'
								+ value.replace(/"/g, 'tags_s')
								+ '" style="color:green;font-size:10pt;"></div><div id="detailPanel_key_'
								+ keySiteFlag + '_'
								+ value.replace(/"/g, 'tags_s') + '"></div>',
						autoScroll : false,
						closable : true
					}).show();

	keywordDs
			.on(
					'beforeload',
					function() {
						document.getElementById('detailPanel_key_'
								+ keySiteFlag + '_'
								+ value.replace(/"/g, 'tags_s')).innerHTML = '<table><tr style="height:10px;"><td colspan=2></td></tr><tr><td style="width:15px;"></td><td style="color:blue;font-size:10pt;"><b>正在加载</b>......</td></tr></table>';
					});

	keywordDs.on('load', function(ds, records) {
		var keybody = '<div style="height:8px;"></div>';
		keybody += '<table><tr><td style="width:8px"></td><td>';
		for ( var k = 0; k < records.length; ++k) {
			keybody += '<span><a href="javascript:searchInType(\''
					+ Ext.util.Format.htmlEncode(value) + '\',\''
					+ Ext.util.Format.htmlEncode(records[k].get('keyword'))
					+ '\',\'关键字\',\'' + keySiteFlag + '\',\'' + globleSiteName
					+ '\')">' + records[k].get('keyword') + '</a>('
					+ records[k].get('num') + ')</span>';
		}
		keybody += '</td><td style="width:8px"></td></tr></table>';
		document.getElementById('detailPanel_key_' + keySiteFlag + '_'
				+ value.replace(/"/g, 'tags_s')).innerHTML = keybody;
	});
	keywordDs.load({
		params : {
			start : 0,
			limit : 150
		},
		callback : function(r, options, success) {
			if (keywordDs.reader.jsonData == '') {
				Ext.MessageBox.alert(TXT_common_hint, TXT_common_relogin,
						function() {
							window.location.href = '../eni/common/logout.jsp';
						});
				return;
			}
		}
	});
}
function tagDetail(value, pnum, knum) {
	keySiteFlag = BestvSearch.DataSourceKey;
	if (document.getElementById(tagSiteFlag + '_' + 'tag_'
			+ value.replace(/"/g, 'tags_s')) != null) {
		mainPanel.setActiveTab(tagSiteFlag + '_' + 'tag_'
				+ value.replace(/"/g, 'tags_s'));
		return;
	}
	var tgDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			fields : [ {
				name : 'tag'
			}, {
				name : 'num'
			} ]
		})
	});
	tgDs.baseParams = {
		cmd : 'keysubject',
		action : 'findEachTagAndNumInPType',
		ptype : value,
		count : knum
	};
	var html;
	html = '<table><tr style="height:8px"><td colspan=2></td></tr>';
	html += '<tr><td style="width:10px"></td><td>节目总数(Program)： ' + pnum
			+ '</td></tr><tr style="height:3px"><td colspan=2></td></tr>';
	html += '<tr><td style="width:10px"></td><td>标签总数(tags)： ' + knum
			+ '</td></tr><tr style="height:5px"><td colspan=2></td></tr>';
	html += '</table>';
	mainPanel
			.add(
					{
						title : '('
								+ globleSiteName
								+ ')'
								+ (value.length > 4 ? (value.substring(0, 4) + '...')
										: value) + ':标签',
						tabTip : '(' + globleSiteName + ')' + value + ':标签',
						iconCls : 'tabs',
						id : tagSiteFlag + '_' + 'tag_'
								+ value.replace(/"/g, 'tags_s'),
						html : '<div id="totalPanel_'
								+ tagSiteFlag
								+ '_'
								+ value.replace(/"/g, 'tags_s')
								+ '" style="color:green;font-size:10pt;"></div><div id="detailPanel_'
								+ tagSiteFlag + '_'
								+ value.replace(/"/g, 'tags_s') + '"></div>',
						autoScroll : false,
						closable : true
					}).show();

	tgDs
			.on(
					'beforeload',
					function() {
						document.getElementById('detailPanel_' + tagSiteFlag
								+ '_' + value.replace(/"/g, 'tags_s')).innerHTML = '<table><tr style="height:10px;"><td colspan=2></td></tr><tr><td style="width:15px;"></td><td style="color:blue;font-size:10pt;"><b>正在加载</b>......</td></tr></table>';
					});
	tgDs.on('load', function(ds, records) {
		var keybody = '<div style="height:8px;"></div>';
		keybody += '<table><tr><td style="width:8px"></td><td>';
		for ( var k = 0; k < records.length; ++k) {
			keybody += '<span><a href="javascript:searchInType(\''
					+ Ext.util.Format.htmlEncode(value) + '\',\''
					+ Ext.util.Format.htmlEncode(records[k].get('tag'))
					+ '\',\'标签\',\'' + tagSiteFlag + '\',\'' + globleSiteName
					+ '\')">' + records[k].get('tag') + '</a>('
					+ records[k].get('num') + ')</span>';
		}
		keybody += '</td><td style="width:8px"></td></tr></table>';
		document.getElementById('detailPanel_' + tagSiteFlag + '_'
				+ value.replace(/"/g, 'tags_s')).innerHTML = keybody;
	});
	tgDs.load({
		params : {
			start : 0,
			limit : 150
		},
		callback : function(r, options, success) {
			if (tgDs.reader.jsonData == '') {
				Ext.MessageBox.alert(TXT_common_hint, TXT_common_relogin,
						function() {
							window.location.href = '../eni/common/logout.jsp';
						});
				return;
			}
		}
	});
}
function keyCross() {
	if (document.getElementById('crossKeyId') != null) {
		mainPanel.setActiveTab('crossKeyId');
		return;
	}
	crossKeyFlag = BestvSearch.DataSourceKey;
	var table = '<table><tr style="height:18px;"><td colspan=2 id="before" style="color:blue;font-size:10pt;"></td></tr><tr><td style="width:50px;"></td><td><table class="matrix"><tbody>'
			+ '<tr class="tr"><td>类型</td><td class="index">新闻</td><td class="index">财经</td><td class="index">娱乐</td><td class="index">电视剧</td></tr>'
			+ '<tr class="tr"><td class="index">新闻</td><td>×</td><td>×</td><td>×</td><td>×</td></tr>'
			+ '<tr class="tr"><td class="index">财经</td><td id="new_fin"></td><td>×</td><td>×</td><td>×</td></tr>'
			+ '<tr class="tr"><td class="index">娱乐</td><td id="new_ent"></td><td id="fin_ent"></td><td>×</td><td>×</td></tr>'
			+ '<tr class="tr"><td class="index">电视剧</td><td id="new_ser"></td><td id="fin_ser"></td><td id="ent_ser"></td><td>×</td></tr>'
			+ '</tbody></table></td></tr></table>';
	crossDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			fields : [ {
				name : 'num'
			} ]
		})
	});
	crossDs.baseParams = {
		cmd : 'keysubject',
		action : 'findCrossKeyword'
	};
	mainPanel
			.add(
					{
						title : '关键字交叉比较',
						id : 'crossKeyId',
						iconCls : 'tabs',
						height : mainPanel.getInnerHeight() * 0.29,
						html : '<div id="cross_table" >'
								+ table
								+ '</div><div id="crossDetail" style="height:70%;"></div>',
						autoScroll : false,
						closable : true
					}).show();
	crossDs
			.on(
					'beforeload',
					function() {
						document.getElementById('before').innerHTML = '正在加载，请稍后...';
						document.getElementById('new_fin').innerHTML = '';
						document.getElementById('fin_ent').innerHTML = '';
						document.getElementById('new_ser').innerHTML = '';
						document.getElementById('fin_ser').innerHTML = '';
						document.getElementById('ent_ser').innerHTML = '';
						document.getElementById('crossDetail').innerHTML = '';
						document.getElementById('new_ent').innerHTML = '<img src="../js/ext/resources/images/default/shared/blue-loading.gif" />';

					});
	crossDs
			.on(
					'load',
					function(ds, records) {
						if (document.getElementById('before') != null)
							document.getElementById('before').innerHTML = '';
						document.getElementById('new_fin').innerHTML = '<a href="javascript:crossDetail(\'新闻\',\'财经\')">'
								+ records[0].get('num') + '</a>';
						document.getElementById('new_ent').innerHTML = '<a href="javascript:crossDetail(\'新闻\',\'娱乐\')">'
								+ records[1].get('num') + '</a>';
						document.getElementById('fin_ent').innerHTML = '<a href="javascript:crossDetail(\'财经\',\'娱乐\')">'
								+ records[2].get('num') + '</a>';
						document.getElementById('new_ser').innerHTML = '<a href="javascript:crossDetail(\'新闻\',\'电视剧\')">'
								+ records[3].get('num') + '</a>';
						document.getElementById('fin_ser').innerHTML = '<a href="javascript:crossDetail(\'财经\',\'电视剧\')">'
								+ records[4].get('num') + '</a>';
						document.getElementById('ent_ser').innerHTML = '<a href="javascript:crossDetail(\'娱乐\',\'电视剧\')">'
								+ records[5].get('num') + '</a>';
					});
	crossDs.load();
}
function handleActivate(tab) {
	if (tab.getId() == 'keyPanel') {
		keyCrossBtn.show();
		if (keySiteFlag != BestvSearch.DataSourceKey && keySiteFlag != '') {
			keySiteFlag = BestvSearch.DataSourceKey;
			keyDs
					.load({
						callback : function(r, options, success) {
							if (r.length == 0) {
								Ext.MessageBox
										.alert(
												TXT_common_hint,
												TXT_common_relogin,
												function() {
													window.location.href = '../eni/common/logout.jsp';
												});
								return;
							}
						}
					});
		}
	} else if (tab.getId() == 'tagPanel') {
		if (tagSiteFlag != BestvSearch.DataSourceKey) {
			tagSiteFlag = BestvSearch.DataSourceKey;
			tagDs
					.load({
						callback : function(r, options, success) {
							if (r.length == 0) {
								Ext.MessageBox
										.alert(
												TXT_common_hint,
												TXT_common_relogin,
												function() {
													window.location.href = '../eni/common/logout.jsp';
												});
								return;
							}
						}
					});
		}
	}
}
function searchInType(ptype, key, searchField, localSC, localName) {
	var rpc = 'tags_s';
	if (searchField == '关键字')
		rpc = 'keys_s';
	var eid = ptype;
	if (ptype == '')
		eid = 'null';
	if (document.getElementById(localSC + '_' + 'id_'
			+ eid.replace(/"/g, rpc).replace(/'/g, rpc) + '_'
			+ key.replace(/"/g, rpc).replace(/'/g, rpc) + '_' + searchField) != null) {
		mainPanel
				.setActiveTab(localSC + '_' + 'id_'
						+ eid.replace(/"/g, rpc).replace(/'/g, rpc) + '_'
						+ key.replace(/"/g, rpc).replace(/'/g, rpc) + '_'
						+ searchField);
		return;
	}
	mainPanel
			.add(
					{
						title : '('
								+ localName
								+ ')'
								+ '搜索('
								+ (key.length > 2 ? (key.substring(0, 2) + '...')
										: key)
								+ ' in '
								+ (ptype.length > 2 ? (ptype.substring(0, 2) + '...')
										: ptype) + '.' + searchField + ')',
						tabTip : '(' + localName + ')' + '搜索结果(' + key + ' in '
								+ ptype + '.' + searchField + ')',
						iconCls : 'tabs',
						id : localSC + '_' + 'id_'
								+ eid.replace(/"/g, rpc).replace(/'/g, rpc)
								+ '_'
								+ key.replace(/"/g, rpc).replace(/'/g, rpc)
								+ '_' + searchField,
						// listeners: {deactivate:
						// function(p){mainPanel.remove(p,true);}},
						html : '<div id="searchGrid_' + localSC + '_'
								+ eid.replace(/"/g, rpc).replace(/'/g, rpc)
								+ '_'
								+ key.replace(/"/g, rpc).replace(/'/g, rpc)
								+ '_' + searchField + '"></div>',
						autoScroll : false,
						closable : true
					}).show();

	if (searchField == '关键字') {
		h1 = '关键字';
		d1 = 'keywords', h2 = '标签';
		d2 = 'tags';
	} else if (searchField == '标签') {
		h2 = '关键字';
		d2 = 'keywords', h1 = '标签';
		d1 = 'tags';
	}

	var searchDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			id : 'id',
			fields : [ {
				name : 'id'
			}, {
				name : 'name'
			}, {
				name : 'type'
			}, {
				name : 'p_type'
			}, {
				name : 'updateTime'
			}, {
				name : 'keywords'
			}, {
				name : 'tags'
			}, {
				name : 'actors'
			}, {
				name : 'directors'
			}, {
				name : 'description'
			} ]
		})
	});
	var field = null;
	if (searchField == '关键字')
		field = 'keyword';
	else if (searchField == '标签')
		field = 'tag';
	searchDs.baseParams = {
		cmd : 'search',
		action : 'searchInOneFieldAndPtypeByOneKeyword',
		key : key,
		ptype : ptype,
		field : field
	};

	keyCrossBtn.hide();
	searchDs.load({
		params : {
			start : 0,
			limit : 17
		}
	});
}

function crossDetail(v1, v2) {
	document.getElementById('crossDetail').innerHTML = '';
	var crossDetailDs = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : DISPATCH_URL
		}),
		reader : new Ext.data.JsonReader({
			root : 'results',
			totalProperty : 'totalCount',
			fields : [ {
				name : 'key'
			} ]
		})
	});
	crossDetailDs.baseParams = {
		cmd : 'keysubject',
		action : 'findCrossKeywordDetail',
		ptype1 : v1,
		ptype2 : v2
	};

	crossDetailDs
			.on(
					'beforeload',
					function() {
						document.getElementById('crossDetailDiv').innerHTML = '<img src="../js/ext/resources/images/default/shared/blue-loading.gif" >正在加载...</img>';
					});
	crossDetailDs.on('load', function(ds, records) {
		var keys = '<div style="height:8px;"></div>';
		keys += '<table><tr><td style="width:8px"></td><td><div>';
		for ( var k = 0; k < records.length; ++k) {
			keys += '<span><a href="javascript:temp(\'' + v2 + '\',\'' + v1
					+ '\',\'' + records[k].get('key') + '\')">'
					+ records[k].get('key') + '</a>；';
		}
		keys += '</td><td style="width:8px"></td></tr></table>';

		document.getElementById('crossDetailDiv').innerHTML = keys;
	});
	crossDetailDs.load({
		params : {
			start : 0,
			limit : 150
		}
	});
}
function temp(p1, p2, keyword) {
	var json = {
		"cmd" : "search",
		"keywords" : keyword,
		"fields" : "keyword",
		"filters" : [ {
			filterField : "p_type",
			filterType : "or",
			filterValue : p1 + '  ' + p2
		} ],
		"order" : "time",
		"forceManual" : "false",// 在搜索接口中加入此参数用以区分是否需要搜索人工绑定域，默认是 true 即需要
		"infoToJSONObj" : "inner",// 在搜索接口中加入此参数用以调用不同的
		// infoToJSONObject方法，默认是outter
		"searchCondition" : "使用关键字 '" + keyword + "' 在关键字域进行搜索垂直分类为 '" + p1
				+ "' 和 '" + p2 + "' 的结果集"
	};
	// window.open("../htm/test.htm?q=" + Ext.util.JSON.encode(json));
	window.location.href = encodeURI("../htm/test.htm?q="
			+ Ext.util.JSON.encode(json));
}

function loadGrid() {
	if (mainPanel.getActiveTab().getId() == 'keyPanel') {
		keyDs
				.load({
					params : {
						start : 0,
						limit : 2
					},
					callback : function(r, options, success) {
						if (r.length == 0) {
							Ext.MessageBox
									.alert(
											TXT_common_hint,
											TXT_common_relogin,
											function() {
												window.location.href = '../eni/common/logout.jsp';
											});
							return;
						}
					}
				});
	} else if (mainPanel.getActiveTab().getId() == 'tagPanel') {
		tagDs
				.load({
					callback : function(r, options, success) {
						if (r.length == 0) {
							Ext.MessageBox
									.alert(
											TXT_common_hint,
											TXT_common_relogin,
											function() {
												window.location.href = '../eni/common/logout.jsp';
											});
							return;
						}
					}
				});
	} else if (mainPanel.getActiveTab().getId() == 'crossKeyId') {
		crossDs.load();
	}
}

Ext.onReady(displaySearchPreview);
